package top.tocchen.bookshop.exception;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.NoHandlerFoundException;

/**
 *
 * 全局异常处理
 *
 * @author tocchen
 * @date 2022/8/10 14:29
 * @since jdk 1.8
 **/
@ControllerAdvice
public class BookShopExceptionHandler {

    Logger log = LoggerFactory.getLogger(BookShopExceptionHandler.class);

    @ExceptionHandler(NoHandlerFoundException.class)
    public String noFound(NoHandlerFoundException e){
        log.error(e.getMessage());
        return "404";
    }
}
